<template>
  <div
    ref="main"
    id="main"
    style="width: 100%; height: 100%; margin: auto"
  ></div>
</template>

<script>
export default {
  props: {
    dataList: {
      type: Object,
    },
  },
  mounted() {
    this.drawChart();
  },
  methods: {
    drawChart() {
      // 基于准备好的dom，初始化echarts实例  这个和上面的main对应
      // let myChart = this.$echarts.init(document.getElementById("main"));
      let myChart = this.$echarts.init(this.$refs.main);
      //职称结构取数

      // var getvalue = [this.dataList.dxRatio, this.dataList.zxRatio, this.dataList.xwRatio];

      //职称结构图表

      // 指定图表的配置项和数据
      let option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        legend: {
          icon: "rect",
          itemGap: 20,
          itemHeight: 12,
          itemWidth: 12,
          textStyle: {
            fontSize: 12, //字体大小
            color: "#38BBEE", //字体颜色
          },
        },
        grid: {
          top: "22%",
          left: "3%",
          right: "4%",
          bottom: "7%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            data: ["成都", "杭州", "南京", "上海", "深圳", "苏州", "武汉"],
            // data: that.data.map((v) => v.融资城市),
            axisLabel: {
              textStyle: {
                color: "#38BBEE",
                //fontSize: 18
              },
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            // name: '总和',
            min: 0,
            // max: 200,
            // interval: (200 - 0) / 5,
            color: "#38BBEE",
            axisLabel: {
              textStyle: {
                color: "#38BBEE",
                //fontSize: 18
              },
              formatter: "{value} ",
            },
          },
          {
            type: "value",
            // name: '增长率',
            min: 0,
            // max: 200,
            // interval: (200 - 0) / 5,
            axisLabel: {
              textStyle: {
                color: "#38BBEE",
                //fontSize: 18
              },
              formatter: "{value}",
            },
            axisLine: {
              lineStyle: {
                color: "#666",
              },
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "#666",
              },
            },
          },
        ],
        series: [
          
          {
            type: "pictorialBar",
            name: "企业数量（千家）",
            yAxisIndex: 0, //使用的 y 轴的 index，在单个图表实例中存在多个 y轴的时候有用
            symbol: "triangle",
            symbolSize: ["50%", "100%"],
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "rgba(0,157,228, 1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0,157,228, 0.2)",
                  },
                ]),
              },
            },

            data: [10.404, 17.879, 69.173, 89.96, 8.8579, 9.300, 6.750],
          },
          {
            type: "pictorialBar",
            name: "上市企业数量",
            symbol: "triangle",
            yAxisIndex: 0, //使用的 y 轴的 index，在单个图表实例中存在多个 y轴的时候有用

            symbolSize: ["50%", "100%"],
            barGap: "-60%", // Make series be overlap
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "rgba(137,48,233, 1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(137,48,233, 0.2)",
                  },
                ]),
              },
            },

            data: [83, 186, 82, 258, 485, 198, 81],
          },
          {
            name: "大型企业占比",
            type: "line",
            symbol: "circle", //标记的图形为实心圆
            symbolSize: 6, //标记的大小
            yAxisIndex: 1, //使用的 y 轴的 index，在单个图表实例中存在多个 y轴的时候有用
            // smooth: true,
            barWidth: 10,
            data: [2.98, 2.67, 0.85, 2.43, 1.56, 1.61, 1.73],
            // data: that.data.map((v) => v.近3个月内有融资企业数量),
            itemStyle: {
              normal: {
                color: "#35FFBF",
              },
            },
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
};
</script>

<style></style>
